package com.hjw.httpclient.controller;

import com.hjw.httpclient.async.MyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.CountDownLatch;

/**
 * @author hjwStrart
 * @time 2022-12-06 20:39
 * @version: 1.0
 */
@RestController
public class HttpAsyncController {

    @Autowired
    private MyService myService;

    @GetMapping("/async")
    public String asyncMethod() {

        myService.setCountDownLatch(new CountDownLatch(5));
        myService.myService();
        return "处理完成";
    }

    @GetMapping("/test")
    public String testMethod() {

        int i = 10 / 0;
        return "处理完成";
    }
}
